package com.CST.controller.ys;

import com.CST.common.api.ResultObject;
import com.CST.dto.ys.AppealDTO;
import com.CST.dto.ys.DetailDTO;
import com.CST.dto.ys.YsDetailDTO;
import com.CST.service.ys.YsAccountDetailService;
import com.CST.service.ys.YsAppealRecordService;
import com.CST.vo.ys.AccountDetailVO;
import com.CST.vo.ys.YsAccountDetailVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author qtx
 * @since 2023-04-21
 */
@RestController
@RequestMapping("/ysExpenseDetail")
@Api(tags = "管理费用类预算执行明细")
public class YsExpenseDetailController {
    private final YsAccountDetailService service;
    private final YsAppealRecordService recordService;
    public YsExpenseDetailController(YsAccountDetailService service, YsAppealRecordService recordService) {
        this.service = service;
        this.recordService = recordService;
    }
    @ApiOperation("分页查询")
    @PostMapping("/listExpenseInfo")
    public ResultObject<YsAccountDetailVO> listBudgetInfo(@RequestBody YsDetailDTO dto) {
        return ResultObject.success(service.listExpenseInfo(dto));
    }

    @ApiOperation("导出")
    @PostMapping("/exportManageExpenseList")
    public ResultObject<String> exportManageExpenseList(@RequestBody YsDetailDTO dto, HttpServletResponse response) {
        return ResultObject.success(service.exportManageExpenseList(dto,response));
    }

    @ApiOperation("申诉回显，查询单条业务预算执行明细")
    @PostMapping("/get_obj")

    public ResultObject<AccountDetailVO> getAccountByNum(@RequestBody DetailDTO params) {
        return ResultObject.success(service.getAccountByNum(params.getNum(),params.getYard(),6));
    }
    @ApiOperation("添加申诉")
    @PostMapping("/add")
    public ResultObject<Integer> addAppeal(@RequestBody AppealDTO dto, HttpServletRequest request) throws IOException {
        dto.setSource(2);
        return ResultObject.success(recordService.addAppeal(dto,request));
    }
}
